package com.fyp.client.ptma.model;

import java.util.ArrayList;
import java.util.List;

import org.simpleframework.xml.Element;
import org.simpleframework.xml.ElementList;
import org.simpleframework.xml.Root;

import android.graphics.Bitmap;
import android.os.Parcel;
import android.os.Parcelable;

@Root(name = "application")
public class Application implements Parcelable
{

	@Element
	private String applicationName;

	@Element(required = false)
	private Long id = 0L;

	@Element
	private String nameSpace;

	@ElementList(name = "versions")
	private List<ApplicationVersion> applicationVersions = new ArrayList<ApplicationVersion>();
	@ElementList(name = "owners", required = false)
	private List<User> users;
	
	private String installedVersion;

	public String getInstalledVersion()
	{
		return installedVersion;
	}

	public void setInstalledVersion(String installedVersion)
	{
		this.installedVersion = installedVersion;
	}

	public List<User> getUsers()
	{
		return users;
	}

	public void setUsers(List<User> users)
	{
		this.users = users;
	}

	public List<ApplicationVersion> getApplicationVersions()
	{
		return applicationVersions;
	}

	private String latestVersion;

	public String getLatestVersion()
	{
		return latestVersion;
	}

	public void setLatestVersion(String latestVersion)
	{
		this.latestVersion = latestVersion;
	}

	public void setApplicationVersions(
			List<ApplicationVersion> applicationVersions)
	{
		this.applicationVersions = applicationVersions;
	}

	private Bitmap applicationIcon;

	public Bitmap getApplicationIcon()
	{
		return applicationIcon;
	}

	public void setApplicationIcon(Bitmap applicationIcon)
	{
		this.applicationIcon = applicationIcon;
	}

	public String getApplicationName()
	{
		return applicationName;
	}

	public void setApplicationName(String applicationName)
	{
		this.applicationName = applicationName;
	}

	public Long getId()
	{
		return id;
	}

	public void setId(Long id)
	{
		this.id = id;
	}

	public String getNameSpace()
	{
		return nameSpace;
	}

	public void setNameSpace(String nameSpace)
	{
		this.nameSpace = nameSpace;
	}

	@Override
	public int describeContents()
	{
		// TODO Auto-generated method stub
		return 0;
	}

	@Override
	public void writeToParcel(Parcel out, int arg1)
	{
		out.writeLong(id);
		out.writeString(applicationName);
		out.writeString(nameSpace);
		out.writeString(latestVersion);
	}

	public Application()
	{

	}

	public static final Parcelable.Creator<Application> CREATOR = new Parcelable.Creator<Application>()
	{
		public Application createFromParcel(Parcel in)
		{
			return new Application(in);
		}

		public Application[] newArray(int size)
		{
			return new Application[size];
		}
	};

	private Application(Parcel in)
	{
		id = in.readLong();
		applicationName = in.readString();
		nameSpace = in.readString();
		latestVersion = in.readString();
	}

}
